package com.fenxiang.tieba.urlHandl;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

/**
 * Created by lixiang on 10/07/2017.
 */
public class MyURLConnection extends URLConnection {

    InputStream in;
    @Override
    public void connect() throws IOException {
        if(connected){
            return;
        }
        url.openConnection();

        int a = 0;
        System.out.println(a);
        connected=true;
    }

    /**
     * Constructs a URL connection to the specified URL. A connection to
     * the object referenced by the URL is not created.
     *
     * @param url the specified URL.
     */
    protected MyURLConnection(URL url) {
        super(url);
    }

//    public InputStream getInputStream()
//            throws IOException {
//        if (!connected)
//            connect();
//        return ( in );
//    }


//    public String getHeaderField(String name)
//    {
//        if ("Content-Type".equalsIgnoreCase(name))
//        {
//            return getContentType();
//
//        }
//        else if ("Content-Length".equalsIgnoreCase(name))
//        {
//            return "" + getContentLength();
//        }
//        return null;
//    }
}
